﻿using Huioo.Learning.Agile.Payroll.Domain;
using Huioo.Learning.Agile.Payroll.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Huioo.Learning.Agile.Payroll.Application
{

    public class ChangeUnaffiliatedTransaction
      : ChangeAffiliationTransaction
    {
        public ChangeUnaffiliatedTransaction(int empId) : base(empId)
        { }
        protected override Affiliation Affiliation
        {
            get { return new NoAffiliation(); }
        }

        //EraseMembership

        protected override void RecordMembership(Employee e)
        {
            Affiliation affiliation = e.Affiliation;
            if (affiliation is UnionAffiliation)
            {
                UnionAffiliation unionAffiliation = affiliation as UnionAffiliation;
                int memberId = unionAffiliation.MemberId;
                PayrollDatabase.RemoveUnionMember(memberId);
            }
        }
    }
}
